#define _CRT_SECURE_NO_WARNINGS 2

#include<iostream>
#include<cstring>
#include<algorithm>
#include<functional>
#include<vector>
#include<memory>

using namespace std;

void fun()
{
	cout << "global........." << endl;
}

class A
{
public:
	A(int  a,int b):a_(a),b_(b){}
	void fun()
	{
		cout << "interal............" << endl;
	}
	virtual void fun1()
	{}
	void test()
	{
		::fun();
	}

	int a_;
	int b_;
};

void test1()
{
	A a(1,2);
	a.test();
}

void test2()
{
	char s[] = "hello, heool  world";
	char* p = strtok(s, "  ");
	while(p != NULL)
	{
		cout << p << endl;
		p = strtok(NULL, " ,");
	}
}

void test3()
{
	char str[] = "- This, a sample string.";
	char* pch;
	printf("Splitting string \"%s\" into tokens:\n", str);
	pch = strtok(str, " ,.-");
	while (pch != NULL)
	{
		printf("%s\n", pch);
		pch = strtok(NULL, " ,.-");
	}
}

void test4()
{
	string s= "- This, a sample string.";
	size_t begin = 0;
	size_t pos = s.find(' ',begin);
	while (pos != string::npos)
	{
		cout << s.substr(begin, pos-begin) << endl;;
		begin = pos + 1;
		pos = s.find(' ', begin);
	}
}

void test5()
{
	vector<shared_ptr<int>> v(5);
	v[0] = make_shared<int>(5);
	weak_ptr<int> w = v[0];
	v[4] = w.lock();
	cout << endl;
}

void test6()
{
	A a1(1,1), a2(2,2);
	swap(a1, a2);
	cout << a1.a_ << endl;
	cout << a2.b_ << endl;
}

template<class T>
class B
{
public:
	B(const T& b):b_(b){}
public:
	int b_;
};

void test7()
{
	string s = "hello\0world";
	cout << s << endl;
}

void test8()
{
	const char* s = "hello world";
	cout << sizeof(s) << endl;
	char buf[] = "hello world";
	cout << sizeof(buf) << endl;
}

void test9()
{
	using it = function<void()>;
	cout << typeid(int).name();
}

int main()
{
	test9();
	return 0;
}